Repository navigation
Reject Drive API v2 field names instead of dropping them - #425
Draft
shcheklein wants to merge 4 commits into
Draft
shcheklein wants to merge 4 commits into
shcheklein wants to merge 4 commits into
Conversation
A temporary live test. It uploads, shares and lists with v2 names such as title and modifiedDate, and fails with a report of what Drive returned. The fix that follows replaces it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The first run showed that Drive accepts {"parents": [{"id": ...}]} without
an error. This run records where such a file is placed.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Drive v3 ignores fields it does not know. A file uploaded with title is named "Untitled", one uploaded with parent objects lands in the root of My Drive, and a list of properties is stored under the wrong keys. Upload() and InsertPermission() now raise for these v2 forms before they send anything. This also removes the temporary probe test. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
shcheklein
commented
Dec 1, 2026
shcheklein
left a comment
Member
Author
There was a problem hiding this comment.
Clean, well-scoped change and great live-probe validation. Left a couple of inline comments on parents shape validation and the value permission hint.
shcheklein
commented
Dec 1, 2026
shcheklein
left a comment
Member
Author
There was a problem hiding this comment.
Two validation gaps found; inline details below.
shcheklein
commented
Dec 1, 2026
There was a problem hiding this comment.
🟡 Changes recommended
Authentication runs before v2 metadata validation in Upload() and InsertPermission(), allowing invalid input to trigger authentication requests or errors instead of the expected migration error.
1 open issue
What changed in this PR
This PR helps PyDrive2 users migrate to Drive API v3 by rejecting known v2 metadata forms rather than allowing uploads or permission changes to silently misbehave.
Changes:
- Add validation errors with migration guidance for legacy file and permission fields.
- Add offline tests for rejected metadata and accepted v3 forms.
- Document date-field replacements and validation behavior in the upgrade guide.
| File | Description |
|---|---|
pydrive2/test/test_files_unit.py |
Tests legacy-field rejection and valid v3 metadata handling. |
pydrive2/files.py |
Adds v2 metadata checks to uploads and permission creation. |
docs/upgrading.rst |
Explains field replacements and migration errors. |
Review effort: Balanced
- Upload() and InsertPermission() validate before authentication starts. - Upload() checks every key of the file, so a metadata read can no longer hide a pending v2 field. - parents must be a list of ID strings; a bare object, a bare ID and None are rejected with the same message. - A tuple of v2 properties is rejected like a list. - The hints for value, indexableText and thumbnail show the full v3 form. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

A program written for PyDrive2 1.x names a file with
titleand places it with a parent object:In 2.0 this upload succeeds and creates a file named "Untitled" in the root of My Drive. Drive API v3 ignores every field it does not know, and the local object still returns
file["title"].What Drive v3 does with v2 metadata
The first two commits are a temporary live test that sent v2 forms to Drive and printed the result (first run, second run).
titleon createtitleon updatecreatedDate,modifiedDate,lastViewedByMeDate,labels,indexableTextparents: [{"id": folder}]on createparents: [{"id": folder}]on updatepropertiesas a list of{key, value, visibility}key,valueandvisibilitywithLink,additionalRolesvalueemailAddressis requiredtitleinqororderByChanges
Upload()raisesValueErrorfor a renamed v2 file field and shows the v3 form:title,createdDate,modifiedDate,lastViewedByMeDate,labels,indexableText,thumbnail.Upload()raisesTypeErrorwhenparentsis not a list of ID strings, and for a list or tuple of v2properties.InsertPermission()raisesValueErrorforvalue,withLink,additionalRolesandexpirationDate.Upload()looks at every key of the file, not only at pending changes, because a metadata read marks local keys as clean.Reads and queries are unchanged.
file["title"], andtitleinqororderBy, already fail with an error.Validation
FileorPermissionschema.expirationDatewas not sent to Drive, because that needs a real user to share with. It is rejected on the strength of the other permission fields being ignored.🤖 Generated with Claude Code